//
//  MusicHeadView.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/6.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "MusicHeadView.h"

@implementation MusicHeadView

- (UIImageView *)bgImageView
{
    if(!_bgImageView)
    {
        UIView *superView = self;
        _bgImageView = [[UIImageView alloc]init];
        [superView addSubview:_bgImageView];
    }
    return _bgImageView;
}
- (UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        UIView *superView = self;
        _nameLabel = [[UILabel alloc]init];
        [superView addSubview:_nameLabel];
        [_nameLabel setFont:fontWithSize(18)];
        [_nameLabel setTextColor:[UIColor whiteColor]];
    }
    return _nameLabel;
}
- (UIButton *)playButton
{
    if(!_playButton)
    {
        UIView *superView = self;
        _playButton = [[UIButton alloc]init];
        [superView addSubview:_playButton];
        [_playButton setTitle:@"全部播放" forState:UIControlStateNormal];
        [_playButton setTitle:@"全部暂停" forState:UIControlStateSelected];
        [_playButton setImage:imageWithName(@"icon_play") forState:UIControlStateNormal];
        [_playButton setImage:imageWithName(@"icon_pause") forState:UIControlStateSelected];
        [_playButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];


    }
    return _playButton;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    
    [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(superView);
    }];
    
    UIView *bottomView = [[UIView alloc] init];
    [superView addSubview:bottomView];
    bottomView.backgroundColor = rgba(0,0,0,0.53);
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(superView);
        make.height.mas_equalTo(px1920Height(128));
    }];
    
    [self.playButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(bottomView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1080Width(61));
        make.width.mas_equalTo(110);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(61));
        make.centerY.mas_equalTo(bottomView.mas_centerY);
        make.right.mas_equalTo(self.playButton.mas_left);
    }];
    
    
}

@end
